<?
	if($_SESSION['is_login'] != true){reHome($urlHome);}
	
	if(isset($_SESSION['uid'])){$u_id = $_SESSION['uid'];}
	

	$sql = "SELECT * FROM ".$prefix."tuyendung WHERE td_nguoidang = '".$u_id."'";

	if(isset($_GET['sid'])){
		$sid = intval($_GET['sid']);
	
		if($sid == 1){
			$sql .= " AND td_trangthai = 0";
		}else if($sid == 2){
		
			$sql .= " AND td_trangthai = 1";
			
		}else if($sid == 3){
		
			$sql .= " ORDER BY td_id DESC";
			
		}else{
			$sql .= " ORDER BY td_id ASC";
		}
	}
	
	//Paging
	$pp=10; 
	$parr=array();
	$parr=paging($sql,$pp);
	$page=$parr[0];
	$limitvalue=$parr[1];
	$numofpages=$parr[2];
	$sql.=" LIMIT $limitvalue, $pp";
	//
	$rs = $db->query($sql);
?>

<script language="javascript">
	function funSort(id,p){
		window.location = '<?=$root?>/?mod=tuyendung&modu=quanlytindang&sid=' + id + '&p=' + p;
	}
</script>
<div id="filtersDescription">
    
	<div class="corner-round-04-top-right">
        <div class="corner-round-04-top-left">
            <div class="corner-round-04-top-bg"></div>
        </div>
    </div>

	<div class="corner-round-04-body"> 
        
        <ul id="descriptionBar" style="margin:0px;">
            <li style="float:left;margin:0px;line-height:20px;">Tìm thấy <b class="highline"><?=$db->num_rows($rs)?></b> tin rao vặt</li>

            <li style="float:right;margin:0px;line-height:20px;" id="menuContainer">
              Sắp xếp theo:
			  <select name="sort" style="width:120px;" onchange="funSort(this.value,'<?=$cid?>','<?=$p?>');">
			 	<option value="0" <? if($sid == 0){?> selected="selected" <? }?>>--- Tất cả ---</option>
				<option value="1" <? if($sid == 1){?> selected="selected" <? }?>>Người tìm việc</option>
				<option value="2" <? if($sid == 2){?> selected="selected" <? }?>>Việc tìm người</option>
				<option value="3" <? if($sid == 3){?> selected="selected" <? }?>>Mới dần</option>
				<option value="4" <? if($sid == 4){?> selected="selected" <? }?>>Cũ dần</option>
			  </select>
			  </li>                       
        </ul>
        <br class="clearBoth" style="font-size:0pt;"/> 
        <p></p>        
                      
    </div>

    <div class="corner-round-04-bottom-right">
        <div class="corner-round-04-bottom-left">
            <div class="corner-round-04-bottom-bg"></div>
        </div>
    </div>   
</div> 

     
                         
            
<!-- Product List { -->
<div id="product-list">
    <div id="product-list-header">       
        <div class="product-col product-col-name">
            <p>Tiêu đề rao vặt</p>

        </div>
        <div class="product-col product-col-price">
            <p>Nơi đăng</p>
        </div>
        <div class="product-col product-col-region">
            <p>Ngày đăng</p>
        </div>
    </div>

    <div style="clear:both;height:4px;font-size:0pt;"></div>
    <div id="product-list-body">
        <div class="corner-round-05-top-right">
            <div class="corner-round-05-top-left">
                <div class="corner-round-05-top-bg"></div>
            </div>
        </div>
        <div class="corner-round-05-body2"> 
            
                <table width="100%" cellpadding="0" cellspacing="0" id="products-items">

			<?
				$st =0;
				 while($row = $db->fetch_array($rs)){
				 $st++;
				 $td_id = $row[td_id];
				 $td_loaituyendung = $row[td_loaituyendung];
				 $td_tieude = $myString->unQuote(stripslashes($row[td_tieude]));
				 $td_mota = $myString->unQuote(stripslashes($row[td_mota]));
				 $td_anhthehien = $PathThumbFile . $row[td_anhthehien];
				 $td_nguoidang = $row[td_nguoidang];
				 $td_nguoidang_ten = tenNguoiDung($row[td_nguoidang]);
				 $td_tinhthanh = layTinhThanh($row[td_tinhthanh]);
				 $td_thoigian = format_date($row[td_ngaydang]);
				 $td_solanxem = $row[td_solanxem];
				 $td_xemgannhat = format_date_time($row[td_xemgannhat]);
				 $td_hienthi = $row[td_hienthi];
				 
			?>
                    <tr>
                        <td class="col-picture">
                            <p> 
                                <a title="<?=$td_tieude?>" href="<?=$root?>/chi-tiet-tuyen-dung/<?=$td_id?>" class="tips product-name">
                                    <img width="100px" style="vertical-align:middle" alt="<?=$td_tieude?>" src="<?=$root?>/<?=$td_anhthehien?>" onerror="this.src='<?=$root?>/themes/images/noimg.jpg';"/>
                                </a>
                            </p> 
                        </td>
                        <td class="col-name">
                            <h1>

                                <a href="<?=$root?>/chi-tiet-tuyen-dung/<?=$td_id?>/<?=$myString->vietdecode($td_tieude)?>" class="product-name" title="<?=$td_tieude?>"><?=$td_tieude?></a>
                            </h1> 
                            <p class="truncate" style="text-align:left;">
                                <?=$myString->cutString2($td_mota,90)?>
                            </p>        
                            <p style="padding-bottom:5px;">                                
                                Người đăng: <a href="<?=$root?>/shop-<?=$td_nguoidang?>/<?=tenNguoiDung2($td_nguoidang)?>" class="popup-profile"> <?=$td_nguoidang_ten?></a>      
                            </p> 
                            <p style="font-size:8pt;color:Gray;">

                                <?=$td_xemgannhat?> | Xem: <?=$td_solanxem?>
                            </p>
							<p align="right"><a href="javascript:void(0);" onclick="javascript:return confirmDelete('<?=$root?>/action.php?act=del_tintuyendung&id=<?=$td_id?>&u_id=<?=$td_nguoidang?>');"><img src="<?=$root?>/themes/images/icon/delete.png" border="0" /></a>&nbsp;<a href="<?=$root?>/sua-tin-tuyen-dung/<?=$td_id?>/<?=$myString->vietdecode($td_tieude)?>"><img src="<?=$root?>/themes/images/icon/edit.png" border="0" /></a></p>
                        </td>
                        <td class="col-price">
                            <p>
                                <?=$td_tinhthanh?>                                        
                            </p>
                        </td>
                        <td class="col-region">
                            <p>

                                <?=$td_thoigian?>
                            </p>
							
                        </td>
                    </tr> 
					
                <? if($st != $db->num_rows($rs)){ ?>
                    <tr>
                        <td colspan="4" style="border-bottom:solid 1px #CCCCCC;height:1px;font-size:0pt;"></td>
                    </tr>                       
				<? } ?>
           <? } 
		   		if($db->num_rows($rs) == 0){
		   ?>     

 				<tr>
					<td align="left" style="padding-left:10px;">Bạn chưa có tin rao vặt nào ! Click vào <a href="<?=$root?>/dang-tin-tuyen-dung/"> Đăng tin </a></td>
				</tr>
           <? } ?>     
                </table> 
                
        </div>
        <div class="corner-round-05-bottom-right">
            <div class="corner-round-05-bottom-left">
                <div class="corner-round-05-bottom-bg"></div>

            </div>
        </div>    
    </div>
    <div id="product-list-footer"></div>
</div>

<!-- Paging { -->


<div id="paging">
    <div class="corner-round-01-top-right">
        <div class="corner-round-01-top-left">
            <div class="corner-round-01-top-bg"></div>

        </div>
    </div>
    <div class="corner-round-01-body" style="text-align:right">            
    <p align="center" class="font">
	 <?php echo page_div( "".$root."/?mod=tuyendung&modu=quanlytindang&sid=".$sid."&p=%d_pg", "10", ceil ( $numofpages ), $page ); ?>
	 </p>
    </div>
    <div class="corner-round-01-bottom-right">
        <div class="corner-round-01-bottom-left">
            <div class="corner-round-01-bottom-bg"></div>
        </div>
    </div>   

</div>   

<!-- } Paging -->

<!-- } Product List -->